package main.Q1101_1200;

public class Q1121_1130 {
	public static void main(String[] args) {
		System.out.println("Question1121：");
		System.out.println("Question1122：数组的相对排序");
		System.out.println("Question1123：");
		System.out.println("Question1124：");
		System.out.println("Question1125：");
		System.out.println("Question1126：");
		System.out.println("Question1127：");
		System.out.println("Question1128：");
		System.out.println("Question1129：");
		System.out.println("Question1130：");
	}
}

class Question1122{
	public int[] relativeSortArray(int[] arr1, int[] arr2) {
		int[] nums = new int[1001];
		int[] result = new int[arr1.length];
		for (int i : arr1) nums[i]++;//遍历arr1,统计每个元素的数量
		int index = 0;//遍历arr2,处理arr2中出现的元素
		for (int i : arr2) {
			while (nums[i]>0){
				result[index++] = i;
				nums[i]--;
			}
		}
		for (int i = 0; i < nums.length; i++) {//遍历nums,处理剩下arr2中未出现的元素
			while (nums[i]>0){
				result[index++] = i;
				nums[i]--;
			}
		}
		return result;
	}
}